import java.util.*;
// 洛谷   P8598 [蓝桥杯 2013 省 AB] 错误票据

public class test3 {
    //链表实现
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        //把回车读走
        scan.nextLine();
        List<Integer> list = new ArrayList<>();
        for(int i = 0;i<n;i++){
            String str = scan.nextLine();
            //把空格取走
            String[] s = str.split(" ");
            for(int j = 0;j<s.length;j++){
                list.add(Integer.parseInt(s[j]));
            }
        }
        //排序链表
        Collections.sort(list);
        //a是重复，b是断号
        int a = -1,b = -1;
        //判断开关
        boolean flaga = false,flagb = false;

        for(int i = 0;i<list.size()-1;i++){
            //重复票据
            if(list.get(i).equals(list.get(i + 1)) && !flaga){
                a = list.get(i);
                flaga = true;
            }
            //断号票据
            if(list.get(i+1)-list.get(i)>1 && !flagb){
                b = list.get(i)+1;
                flagb = true;
            }
            if(flaga && flagb){
                break;
            }
        }
        System.out.println(b+" "+a);
    }


}
